package com.diy.sigmund.diycommon.designpatterns.composite;

import java.util.Iterator;
import java.util.StringJoiner;

/**
 * @author ylm-sigmund
 * @since 2022/2/14 17:02
 */
public class MenuItem extends MenuComponent {

    String name;
    String description;
    boolean vegetarian;
    double price;

    public MenuItem(String name, String description, boolean vegetarian, double price) {
        this.name = name;
        this.description = description;
        this.vegetarian = vegetarian;
        this.price = price;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public boolean isVegetarian() {
        return vegetarian;
    }

    @Override
    public double getPrice() {
        return price;
    }

    @Override
    public void print() {
        System.out.println(new StringJoiner(", ", MenuItem.class.getSimpleName() + "[", "]")
                .add("name='" + name + "'")
                .add("description='" + description + "'")
                .add("vegetarian=" + vegetarian)
                .add("price=" + price));
    }

    @Override
    public Iterator<MenuComponent> createIterator() {
        return new NullIterator();
    }

}
